<template>
  <!-- 维度层级页面 -->
  <div>
    <el-row :gutter="20">
      <el-col :span="18" class="content-left">
<!-- 操作区域 -->
         <upper-template @search = "searchFunc" @clear= "searchForm.treeTypeCode='',searchForm.treeTypeName='',searchForm.caliberProjectName=''">
           <!-- 操作按钮区 -->
           <template slot="buttonArea">
             <el-button  @click="addFunc">新增</el-button>
            <el-button  @click="editFunc">编辑</el-button>
            <el-button  @click="deleteFunc">删除</el-button>
            <el-button  @click="viewFunc">查看</el-button>
            <el-button  @click="configFun">配置层级</el-button>
            <el-button  @click="setAsDefault">设为默认</el-button>
           </template>
           <!-- 搜索区 -->
           <template slot="searchArea">
              <el-form
                  :model="searchForm"
                  ref="searchForm"
                  label-width="100px"
                  label-position="right"
                  size="mini"
                >
                  <el-form-item label="编码：">
                    <el-input v-model="searchForm.treetypeCode" 
                    placeholder="请输入编码"></el-input>
                  </el-form-item>
                  <el-form-item label="名称：" prop="treetypeName">
                    <el-input v-model="searchForm.treetypeName"
                     placeholder="请输入名称" ></el-input>
                  </el-form-item>
                  <el-form-item label="所属维度：" prop="relatedDicttypeCode">
                    <el-select
                      v-model="searchForm.relatedDicttypeCode"
                      placeholder="请选择"
                      style="width:100%"
                    >
                      <el-option v-for="item in relatedDicttypeCodeList" :key="item.dictCode" :label="item.dictName" :value="item.dictCode"></el-option>
                    </el-select>
                  </el-form-item>
                </el-form>
           </template>
           <!-- 显示隐藏区 -->
           <template slot="columnHide">
                <el-checkbox-group v-model="checkList">
                  <el-checkbox
                    v-for="item in textData"
                    :label="item.label"
                    :disabled="item.checkDisabled"
                    :key="item.prop"
                  >{{item.label}}</el-checkbox>
                </el-checkbox-group>
           </template>
          </upper-template>
















        <el-table
          ref="multipleTable"
          :data="tableData"
          style="width: 100%"
          @row-click="getTree"
          id="kind-option"
        >
          <el-table-column width="55" type="selection" fixed="left"></el-table-column>
          <el-table-column
            v-for="(item, key) in showData"
            :key="key"
            :prop="item.prop"
            :label="item.label"
            :show-overflow-tooltip="true"
            :render-header="item.render"
            :sortable="item.sortable"
            :formatter="item.formatter"
            :width="item.width"
            :min-width="item.minwidth"
          ></el-table-column>
          <!-- <el-table-column label="操作" width="180" fixed="right"></el-table-column> -->
        </el-table>
        <pagination
          @size-change="handleSizeChange"
          @current-change="handleCurrentChange"
          :current-page="1"
          :total="400"
        ></pagination>
      </el-col>
      <el-col :span="6" class="content-right">
        <div class="title">
          <div style="float:left"><span class="gun"></span>
          {{treeName}}</div>
    
        </div>
        <el-tree
          :data="treeData"
          :props="defaultProps"
          default-expand-all
          ref="caliberTree"
        ></el-tree>
      </el-col>
    </el-row>
    <!-- 新增编辑查看弹窗 -->
    <el-dialog v-dialogDrag :title="saveTitles[saveFlg]" :visible.sync="addOrEdit" width="35%" top="2%">
      <el-form
        :model="saveForm"
        ref="addTreeForm"
        label-width="120px"
        label-position="left"
        :rules="saveFormRules"
        :disabled="saveFlg==3"
      >
        <el-form-item label="编码：" v-if="saveFlg!=1" prop="treetypeCode">
          <el-input v-model="saveForm.treetypeCode" disabled></el-input>
        </el-form-item>
        <el-form-item label="名称：" prop="treetypeName">
          <el-input v-model="saveForm.treetypeName" ></el-input>
        </el-form-item>
        <el-form-item label="所属维度：" prop="dictCode">
          <el-select v-model="saveForm.dictCode" placeholder="请选择" style="width:100%">
            <el-option v-for="item in relatedDicttypeCodeList" :key="item.dictCode" :label="item.dictName" :value="item.dictCode"></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="描述：" prop="descn">
          <el-input v-model="saveForm.descn" type="textarea" ></el-input>
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button  @click="addOrEdit = false" v-if="saveFlg!=3">确 定</el-button>
        <el-button @click="addOrEdit = false">取 消</el-button>
      </div>
    </el-dialog>
    <!-- 配置层级弹窗 -->
    <el-dialog v-dialogDrag title="口径层级配置" :visible.sync="isConfigDialog" width="70%" top="2%">
      <el-row class="dialogSearchBox" :gutter="10">
        <el-col :span="14">
          <header style="padding:5px;display:flex" v-if="!serachMore">
            <el-input v-model="searchFF.caliberName" placeholder="请输入口径名称" style="width:300px;"></el-input>
            <el-button  style="margin:0 20px">查询</el-button>
            <i class="el-icon-arrow-down" @click="serachMore = true"></i>
          </header>
          <header style="padding:5px;" v-if="serachMore">
            <span>口径编码:</span>
            <el-input
              v-model="searchFF.caliberCode"
              placeholder="请输入口径编码"
              style="width:120px;margin-right:30px"
            ></el-input>
            <span>口径名称:</span>
            <el-input v-model="searchFF.caliberName" placeholder="请输入口径名称" style="width:120px"></el-input>
            <div style="text-align:center;padding:10px">
              <el-button @click="searchFFunc">查询</el-button>
              <el-button @click="searchFF.caliberName='',searchFF.caliberCode=''">重置</el-button>
              <el-button  @click="serachMore = false">收起</el-button>
            </div>
          </header>
          <el-table
            ref="configTable"
            :data="configTableData"
            style="width: 100%"
            @row-click="getConfigTree"
          >
            <el-table-column width="55" type="selection" fixed="left"></el-table-column>
            <el-table-column
              v-for="(item, key) in showConfigData"
              :key="key"
              :prop="item.prop"
              :label="item.label"
              :align="item.align"
              :width="item.width"
              :show-overflow-tooltip="true"
              :render-header="item.render"
              :sortable="item.sortable"
              :formatter="item.formatter"
            ></el-table-column>
            <!-- <el-table-column label="操作" width="180" fixed="right"></el-table-column> -->
          </el-table>
          
            <pagination
          @size-change="handleSizeChange"
          @current-change="handleCurrentChange"
          :current-page="1"
          @refresh = "searchFFunc"
          :pager-count="5"
          :page-size="15"
          :total="40"
        ></pagination>
        </el-col>
        <el-col :span="10" class="content-right">
          <div style="padding: 10px 0">
            <el-button @click="addNextTree">+下级树集</el-button>
            <el-button @click="addNextNode">+下级叶子</el-button>
            <el-button @click="delNode">删除</el-button>
          </div>

          <el-tree
            :data="treeData"
            :props="defaultProps"
            @node-click="handleNodeClick"
            default-expand-all
            show-checkbox
            ref="caliberConfigTree"
            node-key="id"
            check-strictly
            check-on-click-node
            :expand-on-click-node="false"
          ></el-tree>
        </el-col>
      </el-row>

      <el-dialog v-dialogDrag width="35%" title="添加口径集" :visible.sync="isAddNextTree" append-to-body>
        <el-form :model="addTreeForm" ref="addTreeForm">
          <el-form-item label="口径编码" label-width="100px">
            <el-input v-model="addTreeForm.code" autocomplete="off"></el-input>
          </el-form-item>
          <el-form-item label="口径名称" label-width="100px">
            <el-input v-model="addTreeForm.name" autocomplete="off"></el-input>
          </el-form-item>
        </el-form>
        <div slot="footer" class="dialog-footer">
          <el-button  @click="isAddNextTree = false">确 定</el-button>
          <el-button @click="isAddNextTree = false">取 消</el-button>
        </div>
      </el-dialog>
      <div slot="footer" class="dialog-footer">
        </div>
    </el-dialog>
  </div>
</template>

<script>
// import iscroll from 'iscroll'
import { publicManage } from "@/api/index";
import upperTemplate from "@/components/upperTemplate.vue"
export default {
  components:{
    upperTemplate
    },
  data() {
    return {
      treeName: "",
      addOrEdit: false, // 新增/编辑/查看弹窗
      isConfigDialog: false, // 配置层级弹窗
      serachMore: false, // 配置层级搜索是否收起
      isAddNextTree: false, // 添加下级树集弹窗
      saveFlg: 1, // 1:新增，2：编辑，3查看,
      relatedDicttypeCodeList:[{"creator":"sysadmin","createdTm":1583194824036,"modifier":null,"modifiedTm":null,"dictCode":"CustomerId","dictName":"客户","descn":"客户字段","sourceType":"U"},{"creator":"sysadmin","createdTm":1553846301140,"modifier":null,"modifiedTm":null,"dictCode":"EC_SUBJECT_KJ","dictName":"会计科目维度","descn":"会计科目维度","sourceType":"U"},{"creator":"dhliu","createdTm":1566804260554,"modifier":"sysadmin","modifiedTm":1604468629337,"dictCode":"treasurer","dictName":"自营或司库","descn":"用来标识自营业务或司库业务","sourceType":"U"},{"creator":"sysadmin","createdTm":1561038856576,"modifier":null,"modifiedTm":null,"dictCode":"match_id","dictName":"匹配字段","descn":null,"sourceType":"U"},{"creator":"sysadmin","createdTm":1597049549805,"modifier":null,"modifiedTm":null,"dictCode":"000001","dictName":"科目1","descn":null,"sourceType":"U"},{"creator":"sysadmin","createdTm":1551835274207,"modifier":"sysadmin","modifiedTm":1558082029938,"dictCode":"00001","dictName":"机构_CA","descn":"机构 org_unit_id","sourceType":"V"},{"creator":"sysadmin","createdTm":1551835274207,"modifier":"sysadmin","modifiedTm":1571109094945,"dictCode":"00003","dictName":"条线","descn":"条线 business_line","sourceType":"V"},{"creator":"sysadmin","createdTm":1551835274207,"modifier":"sysadmin","modifiedTm":1551835274207,"dictCode":"00004","dictName":"费用科目","descn":"费用科目 gl_account_id","sourceType":"V"},{"creator":null,"createdTm":null,"modifier":"sysadmin","modifiedTm":1545123611000,"dictCode":"productCd","dictName":"产品","descn":"产品字段","sourceType":"V"},{"creator":"sysadmin","createdTm":1542789539000,"modifier":null,"modifiedTm":null,"dictCode":"BussinessUnit","dictName":"业务单元","descn":"用来标识业务单元","sourceType":"V"},{"creator":"sysadmin","createdTm":1542789675000,"modifier":"sysadmin","modifiedTm":1542789756000,"dictCode":"CustomerType","dictName":"客户类别代码","descn":"用来标识客户类别","sourceType":"V"},{"creator":"sysadmin","createdTm":1542789851000,"modifier":"sysadmin","modifiedTm":1545728367000,"dictCode":"GeneralLedger","dictName":"科目","descn":"用来标识交易的所属科目","sourceType":"V"},{"creator":"sysadmin","createdTm":1542789957000,"modifier":null,"modifiedTm":null,"dictCode":"Industry","dictName":"行业代码","descn":"用来标识投向行业","sourceType":"V"},{"creator":"sysadmin","createdTm":1542790039000,"modifier":"sysadmin","modifiedTm":1545101772000,"dictCode":"OrganUnit","dictName":"机构","descn":"用来标识分支机构","sourceType":"V"},{"creator":"sysadmin","createdTm":1545877812000,"modifier":"sysadmin","modifiedTm":1546495375000,"dictCode":"VP_ALM_DIM_QZ","dictName":"债券种类","descn":"债券种类","sourceType":"U"},{"creator":"sysadmin","createdTm":1552872306000,"modifier":"sysadmin","modifiedTm":1552872407000,"dictCode":"001","dictName":"利率类型","descn":null,"sourceType":"U"},{"creator":"sysadmin","createdTm":1586411277164,"modifier":null,"modifiedTm":null,"dictCode":"005","dictName":"机构维度","descn":"机构维度","sourceType":"U"},{"creator":"sysadmin","createdTm":1586414193772,"modifier":null,"modifiedTm":null,"dictCode":"H001","dictName":"国银租赁利润中心","descn":null,"sourceType":"U"},{"creator":"sysadmin","createdTm":1586131576655,"modifier":"sysadmin","modifiedTm":1593479624160,"dictCode":"20200406","dictName":"科目国银","descn":null,"sourceType":"U"},{"creator":"sysadmin","createdTm":1597049247960,"modifier":null,"modifiedTm":null,"dictCode":"130300","dictName":"贷款","descn":null,"sourceType":"U"},{"creator":"sysadmin","createdTm":1597049318364,"modifier":null,"modifiedTm":null,"dictCode":"201100","dictName":"存款","descn":null,"sourceType":"U"},{"creator":"sysadmin","createdTm":1570673295000,"modifier":"sysadmin","modifiedTm":1591345927017,"dictCode":"ProductCd","dictName":"产品IES","descn":"业务经营品种","sourceType":"V"},{"creator":"sysadmin","createdTm":1591345963447,"modifier":null,"modifiedTm":null,"dictCode":"OrganUnit_IES","dictName":"机构IES","descn":null,"sourceType":"U"},{"creator":"sysadmin","createdTm":1582099732211,"modifier":null,"modifiedTm":null,"dictCode":"CurrencyCd","dictName":"币种代码","descn":null,"sourceType":"U"}],
      saveTitles: [
        "新增维度层级",
        "修改维度层级",
        "查看维度层级"
      ],
      searchForm: {},
      saveForm: {
        treeTypeCode: "",
        treeTypeName: "",
        caliberProjectName: "",
        descn: ""
      },
      saveFormRules: {
        treeTypeCode: [
          { required: true, message: "请输入层级树编码", trigger: "blur" }
        ],
        treeTypeName: [
          { required: true, message: "请输入层级树名称", trigger: "blur" },
          { min: 1, max: 20, message: "长度在 1 到 20 个字符", trigger: "blur" }
        ],
        caliberProjectName: [
          { required: true, message: "请选择口径方案", trigger: "blur" }
        ]
      },
      checkList: [],
      // 完整表头字段&&列属性配置
      textData: [
        { prop: "treetypeCode", label: "编码", align: "center",checkDisabled:true },
        { prop: "treetypeName", label: "名称", sortable: true ,checkDisabled:true},
        { prop: "relatedDicttypeCode.dictName", label: "所属维度 " ,checkDisabled:true},
        {
          prop: "defaultTree",
          label: "是否默认",
          formatter: row => {
            return row.defaultTree == 1 ? "是" : "否";
          }
        },
        { prop: "descn", label: "描述" },
        { prop: "creator", label: "创建人" },
        { prop: "createdTm", label: "创建时间",align:"right" },
        { prop: "modifier", label: "修改人" },
        { prop: "modifiedTm", label: "修改时间" ,align:"right"},
      ],
      // 获取table的数据
      tableData: [{"creator":"sysadmin","createdTm":1604450243598,"modifier":null,"modifiedTm":null,"treetypeId":"40288dfd7548c74a017590afd42a0173","treetypeCode":"TR1111","treetypeName":"测试","descn":null,"seq":null,"relatedDicttypeCode":{"creator":null,"createdTm":null,"modifier":"sysadmin","modifiedTm":1545123611000,"dictCode":"productCd","dictName":"产品","descn":"产品字段","sourceType":"V"},"defaultTree":"0"},{"creator":"sysadmin","createdTm":1593769147095,"modifier":null,"modifiedTm":null,"treetypeId":"40288dfd7283b5b00173140b3ae81de1","treetypeCode":"TRtest","treetypeName":"科目测试","descn":null,"seq":null,"relatedDicttypeCode":{"creator":"sysadmin","createdTm":1542789851000,"modifier":"sysadmin","modifiedTm":1545728367000,"dictCode":"GeneralLedger","dictName":"科目","descn":"用来标识交易的所属科目","sourceType":"V"},"defaultTree":"0"},{"creator":"sysadmin","createdTm":1591064397702,"modifier":null,"modifiedTm":null,"treetypeId":"40288dfd72728d94017272d407a2003b","treetypeCode":"TR0021","treetypeName":"省行利润中心树","descn":"省行利润中心树","seq":null,"relatedDicttypeCode":{"creator":"sysadmin","createdTm":1542790039000,"modifier":"sysadmin","modifiedTm":1545101772000,"dictCode":"OrganUnit","dictName":"机构","descn":"用来标识分支机构","sourceType":"V"},"defaultTree":"0"},{"creator":"sysadmin","createdTm":1561036715336,"modifier":null,"modifiedTm":null,"treetypeId":"40288deb6b740065016b7509f55001a5","treetypeCode":"TR99909","treetypeName":"条线_CA","descn":null,"seq":null,"relatedDicttypeCode":{"creator":"sysadmin","createdTm":1551835274207,"modifier":"sysadmin","modifiedTm":1571109094945,"dictCode":"00003","dictName":"条线","descn":"条线 business_line","sourceType":"V"},"defaultTree":"0"},{"creator":"sysadmin","createdTm":1561034884106,"modifier":null,"modifiedTm":null,"treetypeId":"40288deb6b740065016b74ee041000ed","treetypeCode":"TR99905","treetypeName":"省行综合管理部","descn":null,"seq":null,"relatedDicttypeCode":{"creator":"sysadmin","createdTm":1551835274207,"modifier":"sysadmin","modifiedTm":1558082029938,"dictCode":"00001","dictName":"机构_CA","descn":"机构 org_unit_id","sourceType":"V"},"defaultTree":"0"},{"creator":"sysadmin","createdTm":1561034830233,"modifier":null,"modifiedTm":null,"treetypeId":"40288deb6b740065016b74ed319f00e7","treetypeCode":"TR99904","treetypeName":"省行行领导","descn":null,"seq":null,"relatedDicttypeCode":{"creator":"sysadmin","createdTm":1551835274207,"modifier":"sysadmin","modifiedTm":1558082029938,"dictCode":"00001","dictName":"机构_CA","descn":"机构 org_unit_id","sourceType":"V"},"defaultTree":"0"},{"creator":"sysadmin","createdTm":1561034743775,"modifier":null,"modifiedTm":null,"treetypeId":"40288deb6b740065016b74ebdfe500d8","treetypeCode":"TR99903","treetypeName":"市行","descn":null,"seq":null,"relatedDicttypeCode":{"creator":"sysadmin","createdTm":1551835274207,"modifier":"sysadmin","modifiedTm":1558082029938,"dictCode":"00001","dictName":"机构_CA","descn":"机构 org_unit_id","sourceType":"V"},"defaultTree":"0"},{"creator":"sysadmin","createdTm":1561034607306,"modifier":null,"modifiedTm":null,"treetypeId":"40288deb6b740065016b74e9cad300c9","treetypeCode":"TR99902","treetypeName":"省行利润中心","descn":null,"seq":null,"relatedDicttypeCode":{"creator":"sysadmin","createdTm":1551835274207,"modifier":"sysadmin","modifiedTm":1558082029938,"dictCode":"00001","dictName":"机构_CA","descn":"机构 org_unit_id","sourceType":"V"},"defaultTree":"0"},{"creator":"sysadmin","createdTm":1561034521849,"modifier":null,"modifiedTm":null,"treetypeId":"40288deb6b740065016b74e87d0100c2","treetypeCode":"TR99901","treetypeName":"总行利润中心","descn":null,"seq":null,"relatedDicttypeCode":{"creator":"sysadmin","createdTm":1551835274207,"modifier":"sysadmin","modifiedTm":1558082029938,"dictCode":"00001","dictName":"机构_CA","descn":"机构 org_unit_id","sourceType":"V"},"defaultTree":"0"},{"creator":"sysadmin","createdTm":1561025260372,"modifier":null,"modifiedTm":null,"treetypeId":"40288deb6b740065016b745b2b8c0073","treetypeCode":"TR999","treetypeName":"CA主机构树","descn":null,"seq":null,"relatedDicttypeCode":{"creator":"sysadmin","createdTm":1551835274207,"modifier":"sysadmin","modifiedTm":1558082029938,"dictCode":"00001","dictName":"机构_CA","descn":"机构 org_unit_id","sourceType":"V"},"defaultTree":"0"}],
      defaultProps: {
        children: "children",
        label: "label"
      },
      treeData: [
        {
          label: "一级 1",
          children: [
            {
              label: "二级 1-1",
              children: [
                {
                  label: "三级 1-1-1"
                }
              ]
            }
          ]
        },
        {
          label: "一级 2",
          children: [
            {
              label: "二级 2-1",
              children: [
                {
                  label: "三级 2-1-1"
                }
              ]
            },
            {
              label: "二级 2-2",
              children: [
                {
                  label: "三级 2-2-1"
                }
              ]
            }
          ]
        },
        {
          label: "一级 3",
          children: [
            {
              label: "二级 3-1",
              children: [
                {
                  label: "三级 3-1-1"
                }
              ]
            },
            {
              label: "二级 3-2",
              children: [
                {
                  label: "三级 3-2-1"
                }
              ]
            }
          ]
        }
      ],
      searchFF: {
        caliberCode: "",
        caliberName: ""
      },
      // 口径层级配置表格列配置
      showConfigData: [
        { prop: "caliberCode", label: "口径编码", align: "right",width:120},
        { prop: "caliberName", label: "口径名称" },
        { prop: "caliberProject.caliberProjectName", label: "所属口径方案 " }
      ],
      configTableData: [
        {
          creator: "sysadmin",
          createdTm: null,
          modifier: null,
          modifiedTm: null,
          caliberCode: "9900001",
          caliberName: "存量_假日不调整",
          caliberProject: {
            creator: "sys",
            createdTm: 1545823874000,
            modifier: "农发总行管理员",
            modifiedTm: 1595469069877,
            caliberProjectCode: "VP_ALM_COA",
            caliberProjectName: "泛鹏银行资产负债账户册",
            moduleCode: "alm",
            caliberProjectDesc: null
          },
          caliberDesc: null,
          caliberSublevel: "0",
          codeAndName: "9900001--存量_假日不调整"
        },
        {
          creator: "sysadmin",
          createdTm: null,
          modifier: null,
          modifiedTm: null,
          caliberCode: "9900002",
          caliberName: "存量_假日向后",
          caliberProject: {
            creator: "sys",
            createdTm: 1545823874000,
            modifier: "农发总行管理员",
            modifiedTm: 1595469069877,
            caliberProjectCode: "VP_ALM_COA",
            caliberProjectName: "泛鹏银行资产负债账户册",
            moduleCode: "alm",
            caliberProjectDesc: null
          },
          caliberDesc: null,
          caliberSublevel: "0",
          codeAndName: "9900002--存量_假日向后"
        },
        {
          creator: "sysadmin",
          createdTm: null,
          modifier: null,
          modifiedTm: null,
          caliberCode: "9900003",
          caliberName: "存量_假日修正向后",
          caliberProject: {
            creator: "sys",
            createdTm: 1545823874000,
            modifier: "农发总行管理员",
            modifiedTm: 1595469069877,
            caliberProjectCode: "VP_ALM_COA",
            caliberProjectName: "泛鹏银行资产负债账户册",
            moduleCode: "alm",
            caliberProjectDesc: null
          },
          caliberDesc: null,
          caliberSublevel: "0",
          codeAndName: "9900003--存量_假日修正向后"
        },
        {
          creator: "sysadmin",
          createdTm: null,
          modifier: null,
          modifiedTm: null,
          caliberCode: "9900004",
          caliberName: "存量_假日向前",
          caliberProject: {
            creator: "sys",
            createdTm: 1545823874000,
            modifier: "农发总行管理员",
            modifiedTm: 1595469069877,
            caliberProjectCode: "VP_ALM_COA",
            caliberProjectName: "泛鹏银行资产负债账户册",
            moduleCode: "alm",
            caliberProjectDesc: null
          },
          caliberDesc: null,
          caliberSublevel: "0",
          codeAndName: "9900004--存量_假日向前"
        },
        {
          creator: "sysadmin",
          createdTm: null,
          modifier: null,
          modifiedTm: null,
          caliberCode: "9900005",
          caliberName: "存量_假日修正向前",
          caliberProject: {
            creator: "sys",
            createdTm: 1545823874000,
            modifier: "农发总行管理员",
            modifiedTm: 1595469069877,
            caliberProjectCode: "VP_ALM_COA",
            caliberProjectName: "泛鹏银行资产负债账户册",
            moduleCode: "alm",
            caliberProjectDesc: null
          },
          caliberDesc: null,
          caliberSublevel: "0",
          codeAndName: "9900005--存量_假日修正向前"
        },
        {
          creator: "sysadmin",
          createdTm: null,
          modifier: null,
          modifiedTm: null,
          caliberCode: "9900006",
          caliberName: "存量_还款计划",
          caliberProject: {
            creator: "sys",
            createdTm: 1545823874000,
            modifier: "农发总行管理员",
            modifiedTm: 1595469069877,
            caliberProjectCode: "VP_ALM_COA",
            caliberProjectName: "泛鹏银行资产负债账户册",
            moduleCode: "alm",
            caliberProjectDesc: null
          },
          caliberDesc: null,
          caliberSublevel: "0",
          codeAndName: "9900006--存量_还款计划"
        },
        {
          creator: "sysadmin",
          createdTm: null,
          modifier: null,
          modifiedTm: null,
          caliberCode: "9900007",
          caliberName: "存量_指标_固定_到期还本",
          caliberProject: {
            creator: "sys",
            createdTm: 1545823874000,
            modifier: "农发总行管理员",
            modifiedTm: 1595469069877,
            caliberProjectCode: "VP_ALM_COA",
            caliberProjectName: "泛鹏银行资产负债账户册",
            moduleCode: "alm",
            caliberProjectDesc: null
          },
          caliberDesc: null,
          caliberSublevel: "0",
          codeAndName: "9900007--存量_指标_固定_到期还本"
        },
        {
          creator: "sysadmin",
          createdTm: null,
          modifier: null,
          modifiedTm: null,
          caliberCode: "9900008",
          caliberName: "存量_指标_固定_等额本金",
          caliberProject: {
            creator: "sys",
            createdTm: 1545823874000,
            modifier: "农发总行管理员",
            modifiedTm: 1595469069877,
            caliberProjectCode: "VP_ALM_COA",
            caliberProjectName: "泛鹏银行资产负债账户册",
            moduleCode: "alm",
            caliberProjectDesc: null
          },
          caliberDesc: null,
          caliberSublevel: "0",
          codeAndName: "9900008--存量_指标_固定_等额本金"
        },
        {
          creator: "sysadmin",
          createdTm: null,
          modifier: null,
          modifiedTm: null,
          caliberCode: "9900009",
          caliberName: "存量_指标_浮动_到期还本",
          caliberProject: {
            creator: "sys",
            createdTm: 1545823874000,
            modifier: "农发总行管理员",
            modifiedTm: 1595469069877,
            caliberProjectCode: "VP_ALM_COA",
            caliberProjectName: "泛鹏银行资产负债账户册",
            moduleCode: "alm",
            caliberProjectDesc: null
          },
          caliberDesc: null,
          caliberSublevel: "0",
          codeAndName: "9900009--存量_指标_浮动_到期还本"
        },
        {
          creator: "sysadmin",
          createdTm: null,
          modifier: null,
          modifiedTm: null,
          caliberCode: "9900010",
          caliberName: "存量_指标_浮动_等额本金",
          caliberProject: {
            creator: "sys",
            createdTm: 1545823874000,
            modifier: "农发总行管理员",
            modifiedTm: 1595469069877,
            caliberProjectCode: "VP_ALM_COA",
            caliberProjectName: "泛鹏银行资产负债账户册",
            moduleCode: "alm",
            caliberProjectDesc: null
          },
          caliberDesc: null,
          caliberSublevel: "0",
          codeAndName: "9900010--存量_指标_浮动_等额本金"
        }
      ],
      addTreeForm: {
        name: "",
        code: ""
      }
    };
  },
  created() {
    this.checkListInit();
  },
  computed: {
    // 展示字段
    showData() {
      let arr = this.textData.map(v => {
        return v.label;
      });
      let valArr = [],
        showData = [];
      // 选中的字段排序
      arr.forEach(element => {
        let flag = false;
        this.checkList.forEach(e => {
          if (e == element) {
            flag = true;
          }
        });
        if (flag) {
          valArr.push(element);
        }
      });
      // 控制表列隐藏显示
      for (let i = 0; i < this.checkList.length; i++) {
        for (let j = 0; j < this.textData.length; j++) {
          if (this.textData[j].label == valArr[i]) {
            let item = { ...this.textData[j] };
            showData.push(item);
          }
        }
      }
      return showData;
    }
  },
  mounted() {
    // this.getList();
  },
  watch: {},
  methods: {
    checkListInit() {
      this.checkList = this.textData.map(v => {
        return v.label;
      });
    },
    addFunc() {
      this.saveFlg = 1;
      for (let k in this.saveForm) {
        this.saveForm[k] = "";
      }
      this.addOrEdit = true;
    },
    searchFunc(){
      console.log("搜索")
    },
    editFunc() {
      this.saveFlg = 2;
      let selection = this.$refs.multipleTable.selection;
      if (selection.length != 1) {
        return this.$message.warning("请选择一条数据进行修改");
      }
      let row = selection[0];
      let form = {
        treeTypeCode: row.treeTypeCode,
        treeTypeName: row.treeTypeName,
        caliberProjectName: row.caliberProject.caliberProjectName,
        descn: row.descn
      };
      this.saveForm = form;
      this.addOrEdit = true;
    },
    deleteFunc() {
      let selection = this.$refs.multipleTable.selection;
      if (selection.length < 1) {
        return this.$message.warning("请选择要删除的数据");
      }
      this.$confirm("你确认要删除吗？", "提示", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning"
      })
        .then(() => {
          this.$message.success("success");
        })
        .catch(() => {
          this.$message({
            type: "info",
            message: "已取消删除"
          });
        });
    },
    viewFunc() {
      this.saveFlg = 3;
      let selection = this.$refs.multipleTable.selection;
      if (selection.length != 1) {
        return this.$message.warning("请选择一条数据进行修改");
      }
      let row = selection[0];
      let form = {
        treeTypeCode: row.treeTypeCode,
        treeTypeName: row.treeTypeName,
        caliberProjectName: row.caliberProject.caliberProjectName,
        descn: row.descn
      };
      this.saveForm = form;
      this.addOrEdit = true
    },
    setAsDefault() {},
    handleNodeClick() {
      let nodes = this.$refs.caliberConfigTree.getCheckedNodes();
      console.log(nodes);
    },
    caliberProjectNameFormatter(row) {
      return row.caliberProject.caliberProjectName;
    },
    getList() {
      publicManage.query("我的参数").then(res => {
        console.log(res);
      });
    },
    // 获取口径树
    getTree(row) {
      this.treeName = row.treeTypeName;
      this.$refs.multipleTable.toggleRowSelection(row);

    },
    // 获取层级配置口径树
    getConfigTree(row) {
      this.$refs.configTable.toggleRowSelection(row);
    },
    configFun() {
      let checked = this.$refs.multipleTable.selection;
      if (checked.length < 1) {
        return this.$message.warning("请选择一条数据");
      } else if (checked.length > 1) {
        return this.$message.warning("只能选择一条数据");
      } else {
        this.isConfigDialog = true;
      }
    },
    handleSizeChange(val) {
      console.log(`每页 ${val} 条`);
    },
    handleCurrentChange(val) {
      console.log(`当前页: ${val}`);
    },
    // 口径层级配置弹窗左表查询
    searchFFunc(){
      console.log("查询")
    },
    // 增加下级树集
    addNextTree() {
      let node = this.$refs.caliberConfigTree.getCheckedNodes()[0];
      if (node.id !== 1) {
        return this.$message.warning("请选择根节点");
      }
      this.isAddNextTree = true;
    },
    // 增加下级子叶
    addNextNode() {
      let nodes = this.$refs.caliberConfigTree.getCheckedNodes();
      console.log(nodes);
    },
    // 删除节点
    delNode() {
      let nodes = this.$refs.caliberConfigTree.getCheckedNodes();
      console.log(nodes);
      if (nodes.length < 1) {
        return this.$message.warning("请选择要删除的节点");
      }
      this.$confirm("你确认要删除吗？", "提示", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning"
      })
        .then(() => {
          this.$message.success("success");
        })
        .catch(() => {
          this.$message({
            type: "info",
            message: "已取消删除"
          });
        });
    }
  }
};
</script>

<style lang="scss" scoped>
</style>